<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{admin/adminJs}" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-model="http://www.w3.org/1999/xhtml">
<body layout:fragment="content">
<div id="from">
    <el-form label-width="140px" :model="generationConfig"  ref="generationConfig" :rules="rules"  style="padding: 15px;">
        <el-form-item label="表名:" prop="id">
            <el-input v-model="generationConfig.id" style="width: 90%;" readonly></el-input>
        </el-form-item>
        <el-form-item label="java类名:" prop="javaTableName">
            <el-input v-model="generationConfig.javaTableName" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="包名:" prop="packageName">
            <el-input v-model="generationConfig.packageName" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="作者:" prop="author">
            <el-input v-model="generationConfig.author" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="web访问路径:" prop="controllerDirPre">
            <el-input v-model="generationConfig.controllerDirPre" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="生成代码路径:" prop="generatorDir">
            <el-input v-model="generationConfig.generatorDir" style="width: 90%;"></el-input>
        </el-form-item>
        <el-row style="text-align: center">
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="resetForm('generationConfig')">重置</el-button>
            <el-button @click="cancel()">取消</el-button>
        </el-row>
    </el-form>
</div>
<script>

    var id=RequestUtils.getId();
    var tableName=RequestUtils.get('tableName');

    var vm=new Vue({
        el: '#from',
        data:function () {
            var generationConfig=ajaxGet("/admin/system/generation/config/read",{id:id});
            var rules={
                id:ValidateUtils.required('请输入表名!'),
                packageName:ValidateUtils.required('请输入包名!'),
                javaTableName:ValidateUtils.required('请输入java类名!'),
                controllerDirPre:ValidateUtils.required('请输入web访问路径!'),
                author:ValidateUtils.required('请输入作者!'),
                generatorDir:ValidateUtils.required('请输入生成代码路径!')
            };
            return {
                generationConfig:generationConfig,
                rules:rules
            };
        },
        methods:{
            onSubmit:function () {
                this.$refs['generationConfig'].validate(function(valid) {
                    if (valid) {
                        EasyuiUtils.confirmSave("/admin/system/generation/config/save",vm.generationConfig,function () {
                            vm.closeParentDialog(true);
                        });
                    } else {
                       EasyuiUtils.alert('请输入必填项!');
                    }
                });

            },
            cancel:function () {
                vm.closeParentDialog();
            },
            closeParentDialog:function(isRefresh){
                window.parent.closeDialog(isRefresh);
            },
            resetForm:function(formName) {
                this.$refs[formName].resetFields();
            }
        }
    });
</script>

</body>
</html>